package kr.hkit.powerjava.chapter22.work;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import javax.swing.JOptionPane;

public class TestMain {

	public static void main(String[] args) {
		ArrayList<Student> stdList = new ArrayList<>();
		initList(stdList);
		prnList(stdList);
		
		/*Student std = new Student(2, "이민정");
		
		//System.out.println(stdList.indexOf(std) + "의 위치에 존재" + stdList.contains(std));
		//System.out.println(stdList.lastIndexOf(std) + "의 위치에 존재" + stdList.contains(std));
		
		System.out.println("------------------------------------------------------");
		Collections.sort(stdList);//총점순 정렬 Comparable
		prnList(stdList);
		
		System.out.println("------------------------------------------------------");
		//수학점수별 정렬
		Comparator<Student> mathcomp = new Comparator<Student>() {
			
			@Override
			public int compare(Student o1, Student o2) {
				return o1.getMathScore() - o2.getMathScore();
			}
		};
		Collections.sort(stdList, mathcomp);
		prnList(stdList);*/
		
		StudentManager sm = new StudentManager(stdList);
		sm.prnList();
		
		Student std = new Student(stdList.size()+1, "제시카", 90, 85, 55);
		
		sm.addStudnet(std);
		sm.prnList();
		
		sm.delStudent(std);
		sm.prnList();
		int res = 0;
		do{
			//prnMenu();
			System.out.println("메뉴를 선택하세요");
			try{
			res = Integer.parseInt(JOptionPane.showInputDialog("1. 추가 2. 검색 3. 수정 4. 삭제 5.리스트 출력 6. 종료"));
			}catch(NumberFormatException e){
				res = 6;
			}
			switch(res){
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
				default:
					break;
			}
		}while(res < 6);
	}

	

	private static void prnList(ArrayList<Student> stdList) {
		for(Student std: stdList){
			System.out.println(std);
		}
	}

	private static void initList(ArrayList<Student> stdList) {
		stdList.add(new Student(1, "김태희", 87, 87, 87));
		stdList.add(new Student(2, "이민정", 90, 87, 87));
		stdList.add(new Student(3, "이소은", 70, 70, 87));
		stdList.add(new Student(4, "남주호", 60, 65, 65));
		stdList.add(new Student(5, "신한욱", 50, 55, 50));
		stdList.add(new Student(6, "이민정", 90, 87, 100));
	}

}
